using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using System;
using System.Collections.Generic;
namespace MicroMsg.Scene.ChatRoom
{
	public class NetSceneDelChatRoomMember : NetSceneBaseEx<DelChatRoomMemberRequest, DelChatRoomMemberResponse, DelChatRoomMemberRequest.Builder>
	{
		private const string TAG = "NetSceneDelChatRoomMember";
		public bool doScene(string chatRoomName, List<string> memberList)
		{
			if (memberList != null && memberList.get_Count() != 0 && !string.IsNullOrEmpty(chatRoomName))
			{
				Log.smethod_4("NetSceneDelChatRoomMember", "doscene begin");
				base.beginBuilder();
				this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
				this.mBuilder.ChatRoomName = chatRoomName;
				using (List<string>.Enumerator enumerator = memberList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						string current = enumerator.get_Current();
						this.mBuilder.MemberListList.Add(DelMemberReq.CreateBuilder().SetMemberName(Util.toSKString(current)).Build());
					}
				}
				this.mBuilder.MemberCount = (uint)memberList.get_Count();
				this.mSessionPack.mCmdUri = "/cgi-bin/micromsg-bin/delchatroommember";
				this.mSessionPack.mConnectMode = 2;
				base.endBuilder();
				return true;
			}
			Log.smethod_5("NetSceneDelChatRoomMember", "doScene,invalid input para");
			return false;
		}
		protected override void onFailed(DelChatRoomMemberRequest request, DelChatRoomMemberResponse response)
		{
			Log.smethod_1("NetSceneDelChatRoomMember", "send AddChatRoomMemberRequest failed");
			EventCenter.postEvent(EventConst.ON_NETSCENE_DEL_CHATROOM_MEMBER_ERR, new NetSceneDelChatRoomMemberResult
			{
				retCode = RetConst.MM_ERR_CLIENT,
				sceneDelChatRoomMember = this
			}, null);
		}
		protected override void onSuccess(DelChatRoomMemberRequest request, DelChatRoomMemberResponse response)
		{
			Log.smethod_4("NetSceneDelChatRoomMember", "doscene respone sucess");
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			NetSceneDelChatRoomMemberResult netSceneDelChatRoomMemberResult = new NetSceneDelChatRoomMemberResult();
			netSceneDelChatRoomMemberResult.retCode = (RetConst)response.BaseResponse.Ret;
			netSceneDelChatRoomMemberResult.sceneDelChatRoomMember = this;
			netSceneDelChatRoomMemberResult.nameList = new List<string>();
			for (int i = 0; i < response.MemberListList.get_Count(); i++)
			{
				netSceneDelChatRoomMemberResult.nameList.Add(response.MemberListList.get_Item(i).MemberName.String);
			}
			if (netSceneDelChatRoomMemberResult.retCode != RetConst.MM_OK)
			{
				Log.smethod_1("NetSceneDelChatRoomMember", "send AddChatRoomMemberRequest failed ret =" + ret);
				EventCenter.postEvent(EventConst.ON_NETSCENE_DEL_CHATROOM_MEMBER_ERR, netSceneDelChatRoomMemberResult, null);
				return;
			}
			if (!ChatRoomMgr.delChatroomMember(request.ChatRoomName, response))
			{
				Log.smethod_1("NetSceneDelChatRoomMember", "delChatroomMember : fail");
				EventCenter.postEvent(EventConst.ON_NETSCENE_DEL_CHATROOM_MEMBER_ERR, netSceneDelChatRoomMemberResult, null);
				return;
			}
			Log.smethod_4("NetSceneDelChatRoomMember", "doscene post sucess");
			EventCenter.postEvent(EventConst.ON_NETSCENE_DEL_CHATROOM_MEMBER_SUCCESS, netSceneDelChatRoomMemberResult, null);
		}
	}
}
